if(typeof GameView == "undefined") GameView = {
	param: {}
};

GameView.bid = {
	click: function() {
		if(chuquan.btn.hasClass("active")) return;
		BC.getBalance().then(function(result) {
			if(GameView.param.stake > result.toNumber()) {
				AlertView.layer.alert("错误", "余额不足");
			} else {
				var content = AlertView.SubmitChoiceHtml.getHtml();
				AlertView.layer.open("出加密拳", content, function() {
					AlertView.SubmitChoiceHtml.init(GameView.bid);
				}, {
					area: ['30rem', '16rem']
				});
			}
		}).catch(GameView.bid.error);

	},
	submitClick: function() {
		GameView.param.choice = AlertView.SubmitChoiceHtml.getSelecter().val();
		GameView.param.secret = AlertView.SubmitChoiceHtml.getInput().val();
		GameView.param.bindId = '0x' + keccak256(GameView.param.choice + GameView.param.secret);
		AlertView.layer.loading("正在提交中(大约1分钟,请勿关闭)...");
		BC.do("bid", {
			hashId: "0x" + GameView.param.gameId,
			blindedBid: GameView.param.bindId
		}).
		then(function(result) {
			if(result.logs.length > 0) {
				GameView.bid.success(result);
			} else {
				GameView.bid.error({code:200,msg:"未知"});
			}
		}).catch(GameView.bid.error);
	},
	
	success:function(result){
		var log = result.logs[0];
	},
	error:function(result){
		AlertView.layer.alert("错误", err.msg);
	}
}